// import {
// 	BookModel
// } from '../../models/book.js'

// console.log(bookModel)
class KeywordModel {
	key = 'q'
	max = 10

	getHistory() {
		var keywords = wx.getStorageSync(this.key)
		return keywords
	}

	getHot(success) {
		// this.request({
		//   url:'/book/hot_keyword',
		//   success:success
		// })
		// var result = await BookModel.getHot();
		// console.log(result)
		
	}


	addToHistory(word) {
		let keywords = this.getHistory()
		if (keywords) {
			let index = keywords.indexOf(word)
			if (index == -1) {
				let length = keywords.length
				if (length >= this.max) {
					keywords.pop(word)
				}
				keywords.unshift(word)
			}
			wx.setStorageSync(this.key, keywords)
		} else {
			keywords = [word]
			wx.setStorageSync(this.key, keywords)
		}
	}
}

export {
	KeywordModel
}
